//
//  IntroScene.m
//  cocos2dt1
//
//  Created by mmac on 1/17/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "HelloWorldScene.h"

#import "IntroScene.h"
#import "LevelScene.h"

@implementation IntroScene

+(id) scene
{
	// 'scene' is an autorelease object.
	Scene *scene = [Scene node];
	
	// 'layer' is an autorelease object.
	IntroScene *layer = [IntroScene node];
	
	// add layer as a child to scene
	[scene addChild: layer];
	
	// return the scene
	return scene;
}

// on "init" you need to initialize your instance
-(id) init
{
	// always call "super" init
	// Apple recommends to re-assign "self" with the "super" return value
	if( (self=[super init] )) {
		
		self.isTouchEnabled = YES;

		// create and initialize a Label
		Label* label = [Label labelWithString:@"Intro" fontName:@"Marker Felt" fontSize:64];
		
		// ask director the the window size
		CGSize size = [[Director sharedDirector] winSize];
		
		// position the label on the center of the screen
		label.position =  ccp( size.width /2 , size.height/2 );
		
		// add the label as a child to this Layer
		[self addChild: label];
	}
	return self;
}

- (BOOL)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
	UITouch *touch = [touches anyObject];
	
	if( touch ) {
		// CGPoint location = [touch locationInView: [touch view]];
		
		// IMPORTANT:
		// The touches are always in "portrait" coordinates. You need to convert them to your current orientation
		// CGPoint convertedPoint = [[Director sharedDirector] convertCoordinate:location];
		
		// CocosNode *sprite = [self getChildByTag:kTagSprite];
		
		// we stop the all running actions
		// [sprite stopAllActions];
		
		// and we run a new action
		// [sprite runAction: [MoveTo actionWithDuration:1 position:convertedPoint]];
		
		[[Director sharedDirector] replaceScene: [FadeTransition transitionWithDuration:0.5 scene:[LevelScene scene] ]];
		// [[Director sharedDirector] replaceScene: [FadeBLTransition transitionWithDuration:0.5 scene:[LevelScene scene] ]];
		// [[Director sharedDirector] replaceScene: [FadeDownTransition transitionWithDuration:0.5 scene:[LevelScene scene] ]];
		// [[Director sharedDirector] replaceScene: [FadeTRTransition transitionWithDuration:0.5 scene:[LevelScene scene] ]];
		// [[Director sharedDirector] replaceScene: [FlipAngularTransition transitionWithDuration:0.5 scene:[LevelScene scene] ]];
		// [[Director sharedDirector] replaceScene: [JumpZoomTransition transitionWithDuration:0.5 scene:[LevelScene scene] ]];
		// [[Director sharedDirector] replaceScene: [ShrinkGrowTransition transitionWithDuration:0.5 scene:[LevelScene scene] ]];

		
		// no other handlers will receive this event
		return kEventHandled;
	}
	
	// we ignore the event. Other receivers will receive this event.
	return kEventIgnored;
}

// on "dealloc" you need to release all your retained objects
- (void) dealloc
{
	// in case you have something to dealloc, do it in this method
	// in this particular example nothing needs to be released.
	// cocos2d will automatically release all the children (Label)
	
	// don't forget to call "super dealloc"
	[super dealloc];
}
@end


